package com.cswnode.demo.util;

import com.cswnode.demo.entity.User;
import org.springframework.stereotype.Component;

/**
 * @author csw
 * @create 2020/9/18 14:23
 */
@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user){
        users.set(user);
    }

    public User getUser(){
        return users.get();
    }
    public void clear(){
        users.remove();
    }


}
